package API.DAY4.collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class SortString {
    public static void main(String[] args) {
        /*
        List<String> list = new ArrayList<>();
        list.add("axa");
        list.add("adb");
        list.add("dbc");
        list.add("dad");
        System.out.println(list);
        Collections.sort(list);
        System.out.println(list);

         */
        List<String> list = new ArrayList<>();
        list.add("地沟");
        list.add("水煮鱼雨");
        list.add("毛丢丢");
        list.add("狗头");
        System.out.println(list);

//        Collections.sort(list, new Comparator<String>() {
//            @Override
//
//            public int compare(String o1, String o2) {
////                return o1.length()-o2.length();
//                return o2.length()-o1.length();
//            }
//        });


        Collections.sort(list,(o1, o2)->o1.length()-o2.length());
        System.out.println(list);
    }
}
